package com.xjh.basestudy.javabase.io.byteio;

import java.io.*;

public class BufferedOutputStream1 {
    public static void main(String[] args) throws IOException {
//        FileOutputStream fos = new FileOutputStream("javabase\\bos.txt");
//        BufferedOutputStream bos = new BufferedOutputStream(fos);
        //将上面两步直接合在一步里,new对象的时候new地址
        //建立字节缓冲输出流
//        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("javabase\\bos.txt"));
//        //写数据
//        bos.write("hello\r\n".getBytes());
//        bos.write("world\r\n".getBytes());
        //读数据
        //建立字节缓冲输入流
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\bos.txt"));
        //一次读一个字节数据
//        int by;
//        while((by=bis.read())!=-1){
//            System.out.println((char)by);
//        }D:
        //一次读一个字节数据数组
        byte[] bys = new byte[1024];
        int len;
        while((len=bis.read())!=-1){
            System.out.println(new String(bys,0,len));
        }
        System.out.println(len);
        bis.close();
    }
}
